﻿namespace HRM.CORE.Process
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraLayout;
    using DevExpress.XtraLayout.Utils;
    using Microsoft.VisualBasic;
    using APP.HELPER;
    using HRM.CORE;
    using HRM.CORE.CLASS;
    
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using Common;
    using APP.HELPER.Utils.Language;
    using Security.ERP;

    public class xucAssignmentAdd : Common.xucBaseAddH
    {
        private CalcEdit calDebtMoney;
        private CalcEdit calMoney;
        private CalcEdit calPayMoney;
        private TextEdit cboDecideNumber;
        private TextEdit cboPerson;
        private TextEdit cboWhere;
        private GridColumn colEmployeeCode;
        private GridColumn colFirstName;
        private GridColumn colLastName;
        private IContainer components = null;
        private DateEdit dtDate;
        private DateEdit dtFromDate;
        private DateEdit dtToDate;
        private GridLookUpEdit glkEmployeeCode;
        private GridView gridLookUpEdit1View;
        private GroupControl grInformation;
        private LabelControl labelControl1;
        private LabelControl labelControl7;
        private LayoutControl layoutControl1;
        private LayoutControlGroup layoutControlGroup1;
        private LayoutControlItem layoutControlItem1;
        private LayoutControlItem layoutControlItem2;
        private LayoutControlItem lcAssignmentName;
        private LayoutControlItem lcDate;
        private LayoutControlItem lcDecideNumber;
        private LayoutControlItem lcDecidePerson;
        private LayoutControlItem lcFromDate;
        private LayoutControlItem lcMoney;
        private LayoutControlItem lcReason;
        private LayoutControlItem lcToDate;
        private LayoutControlItem lcWhere;
        private Guid m_AssignmentID = Guid.Empty;
        private string m_EmployeeCode = "";
        private TextEdit txtAssignmentName;
        private TextEdit txtEmployeeName;
        private ButtonEdit txtFilePath;
        private TextEdit txtReason;

        public event SuccessEventHander Success;

        public xucAssignmentAdd()
        {
            this.InitializeComponent();
            this.InitComponent();
            this.InitData();
        }

        protected override void Add()
        {
            base.Add();
            HRM_PROCESS_ASSIGNMENT hrm_process_assignment = new HRM_PROCESS_ASSIGNMENT();
            this.txtAssignmentName.Focus();
        }

        private void calMoney_EditValueChanged(object sender, EventArgs e)
        {
            decimal num = decimal.Parse(this.calMoney.EditValue.ToString());
            decimal num2 = decimal.Parse(this.calPayMoney.EditValue.ToString());
            this.calDebtMoney.EditValue = num - num2;
        }

        public void Clear()
        {
            this.txtAssignmentName.Text = "";
            this.txtReason.Text = "";
            this.cboWhere.Text = "";
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void glkEmployeeCode_EditValueChanged(object sender, EventArgs e)
        {
            this.m_EmployeeCode = this.glkEmployeeCode.EditValue.ToString();
            this.LoadEmployeeInformation();
        }

        protected override void Init()
        {
        }

        private HRM_PROCESS_ASSIGNMENT InitClass()
        {
            return new HRM_PROCESS_ASSIGNMENT { AssignmentID = Guid.NewGuid(), EmployeeCode = this.m_EmployeeCode, AssignmentName = this.txtAssignmentName.Text, Reason = this.txtReason.Text, Where = this.cboWhere.Text, FromDate = this.dtFromDate.DateTime, ToDate = this.dtToDate.DateTime, Money = decimal.Parse(this.calMoney.Text), PayMoney = decimal.Parse(this.calPayMoney.Text), DebtMoney = decimal.Parse(this.calDebtMoney.Text), Date = this.dtDate.DateTime, DecideNumber = this.cboDecideNumber.Text, Person = this.cboPerson.Text, FilePath = this.txtFilePath.Text };
        }

        private void InitComponent()
        {
            this.dtFromDate.DateTime = DateTime.Now;
            this.dtToDate.DateTime = DateTime.Now;
            this.dtDate.DateTime = DateTime.Now;
        }

        private void InitData()
        {
            new HRM_EMPLOYEE().AddGridLookupEdit(this.glkEmployeeCode);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucAssignmentAdd));
            SerializableAppearanceObject appearance = new SerializableAppearanceObject();
            this.grInformation = new GroupControl();
            this.labelControl1 = new LabelControl();
            this.txtEmployeeName = new TextEdit();
            this.glkEmployeeCode = new GridLookUpEdit();
            this.gridLookUpEdit1View = new GridView();
            this.colEmployeeCode = new GridColumn();
            this.colFirstName = new GridColumn();
            this.colLastName = new GridColumn();
            this.layoutControl1 = new LayoutControl();
            this.calDebtMoney = new CalcEdit();
            this.calPayMoney = new CalcEdit();
            this.txtAssignmentName = new TextEdit();
            this.dtFromDate = new DateEdit();
            this.dtDate = new DateEdit();
            this.txtReason = new TextEdit();
            this.cboWhere = new TextEdit();
            this.dtToDate = new DateEdit();
            this.calMoney = new CalcEdit();
            this.cboPerson = new TextEdit();
            this.cboDecideNumber = new TextEdit();
            this.layoutControlGroup1 = new LayoutControlGroup();
            this.lcAssignmentName = new LayoutControlItem();
            this.lcReason = new LayoutControlItem();
            this.lcWhere = new LayoutControlItem();
            this.lcFromDate = new LayoutControlItem();
            this.lcToDate = new LayoutControlItem();
            this.lcDecidePerson = new LayoutControlItem();
            this.lcDate = new LayoutControlItem();
            this.lcDecideNumber = new LayoutControlItem();
            this.lcMoney = new LayoutControlItem();
            this.layoutControlItem1 = new LayoutControlItem();
            this.layoutControlItem2 = new LayoutControlItem();
            this.labelControl7 = new LabelControl();
            this.txtFilePath = new ButtonEdit();
            ((ISupportInitialize) base.Err).BeginInit();
            base.imageCollection2.BeginInit();
            this.grInformation.BeginInit();
            this.grInformation.SuspendLayout();
            this.txtEmployeeName.Properties.BeginInit();
            this.glkEmployeeCode.Properties.BeginInit();
            this.gridLookUpEdit1View.BeginInit();
            this.layoutControl1.BeginInit();
            this.layoutControl1.SuspendLayout();
            this.calDebtMoney.Properties.BeginInit();
            this.calPayMoney.Properties.BeginInit();
            this.txtAssignmentName.Properties.BeginInit();
            this.dtFromDate.Properties.VistaTimeProperties.BeginInit();
            this.dtFromDate.Properties.BeginInit();
            this.dtDate.Properties.VistaTimeProperties.BeginInit();
            this.dtDate.Properties.BeginInit();
            this.txtReason.Properties.BeginInit();
            this.cboWhere.Properties.BeginInit();
            this.dtToDate.Properties.VistaTimeProperties.BeginInit();
            this.dtToDate.Properties.BeginInit();
            this.calMoney.Properties.BeginInit();
            this.cboPerson.Properties.BeginInit();
            this.cboDecideNumber.Properties.BeginInit();
            this.layoutControlGroup1.BeginInit();
            this.lcAssignmentName.BeginInit();
            this.lcReason.BeginInit();
            this.lcWhere.BeginInit();
            this.lcFromDate.BeginInit();
            this.lcToDate.BeginInit();
            this.lcDecidePerson.BeginInit();
            this.lcDate.BeginInit();
            this.lcDecideNumber.BeginInit();
            this.lcMoney.BeginInit();
            this.layoutControlItem1.BeginInit();
            this.layoutControlItem2.BeginInit();
            this.txtFilePath.Properties.BeginInit();
            base.SuspendLayout();
            base.btnSave.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            base.btnSave.Location = new Point(0x89, 0x111);
            base.btnSave.TabIndex = 1;
            base.btnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            base.btnCancel.Location = new Point(0x151, 0x111);
            base.btnCancel.TabIndex = 3;
            base.btnSaveNew.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            base.btnSaveNew.Location = new Point(0xec, 0x111);
            base.btnSaveNew.TabIndex = 2;
            base.imageCollection2.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection2.ImageStream");
            this.grInformation.Controls.Add(this.labelControl1);
            this.grInformation.Controls.Add(this.txtEmployeeName);
            this.grInformation.Controls.Add(this.glkEmployeeCode);
            this.grInformation.Controls.Add(this.layoutControl1);
            this.grInformation.Dock = DockStyle.Top;
            this.grInformation.Location = new Point(0, 0);
            this.grInformation.Name = "grInformation";
            this.grInformation.Size = new Size(0x1bb, 0x103);
            this.grInformation.TabIndex = 0;
            this.grInformation.Text = "Th\x00f4ng Tin C\x00f4ng T\x00e1c";
            this.labelControl1.AllowHtmlString = true;
            this.labelControl1.Location = new Point(10, 0x1d);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x3e, 14);
            this.labelControl1.TabIndex = 0;
            this.labelControl1.Text = "Chọn NV <color=red>(*)</color>:";
            this.txtEmployeeName.Enabled = false;
            this.txtEmployeeName.Location = new Point(210, 0x1b);
            this.txtEmployeeName.Name = "txtEmployeeName";
            this.txtEmployeeName.Size = new Size(0xde, 20);
            this.txtEmployeeName.TabIndex = 2;
            this.glkEmployeeCode.Location = new Point(0x5e, 0x1b);
            this.glkEmployeeCode.Name = "glkEmployeeCode";
            this.glkEmployeeCode.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkEmployeeCode.Properties.NullText = "[Chọn nh\x00e2n vi\x00ean]";
            this.glkEmployeeCode.Properties.View = this.gridLookUpEdit1View;
            this.glkEmployeeCode.Size = new Size(110, 20);
            this.glkEmployeeCode.TabIndex = 1;
            this.glkEmployeeCode.EditValueChanged += new EventHandler(this.glkEmployeeCode_EditValueChanged);
            this.gridLookUpEdit1View.Columns.AddRange(new GridColumn[] { this.colEmployeeCode, this.colFirstName, this.colLastName });
            this.gridLookUpEdit1View.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridLookUpEdit1View.Name = "gridLookUpEdit1View";
            this.gridLookUpEdit1View.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridLookUpEdit1View.OptionsView.ShowAutoFilterRow = true;
            this.gridLookUpEdit1View.OptionsView.ShowGroupPanel = false;
            this.colEmployeeCode.Caption = "M\x00e3 nh\x00e2n vi\x00ean";
            this.colEmployeeCode.FieldName = "EmployeeCode";
            this.colEmployeeCode.Name = "colEmployeeCode";
            this.colEmployeeCode.Visible = true;
            this.colEmployeeCode.VisibleIndex = 0;
            this.colFirstName.Caption = "Họ l\x00f3t";
            this.colFirstName.FieldName = "FirstName";
            this.colFirstName.Name = "colFirstName";
            this.colFirstName.Visible = true;
            this.colFirstName.VisibleIndex = 1;
            this.colLastName.Caption = "T\x00ean";
            this.colLastName.FieldName = "LastName";
            this.colLastName.Name = "colLastName";
            this.colLastName.Visible = true;
            this.colLastName.VisibleIndex = 2;
            this.layoutControl1.Controls.Add(this.calDebtMoney);
            this.layoutControl1.Controls.Add(this.calPayMoney);
            this.layoutControl1.Controls.Add(this.txtAssignmentName);
            this.layoutControl1.Controls.Add(this.dtFromDate);
            this.layoutControl1.Controls.Add(this.dtDate);
            this.layoutControl1.Controls.Add(this.txtReason);
            this.layoutControl1.Controls.Add(this.cboWhere);
            this.layoutControl1.Controls.Add(this.dtToDate);
            this.layoutControl1.Controls.Add(this.calMoney);
            this.layoutControl1.Controls.Add(this.cboPerson);
            this.layoutControl1.Controls.Add(this.cboDecideNumber);
            this.layoutControl1.Location = new Point(6, 0x34);
            this.layoutControl1.Name = "layoutControl1";
            this.layoutControl1.OptionsView.AllowHotTrack = true;
            this.layoutControl1.OptionsView.HighlightDisabledItem = true;
            this.layoutControl1.OptionsView.HighlightFocusedItem = true;
            this.layoutControl1.Root = this.layoutControlGroup1;
            this.layoutControl1.Size = new Size(430, 0xc9);
            this.layoutControl1.TabIndex = 3;
            this.layoutControl1.Text = "layoutControl1";
            int[] bits = new int[4];
            this.calDebtMoney.EditValue = new decimal(bits);
            this.calDebtMoney.Location = new Point(0x58, 0x92);
            this.calDebtMoney.Name = "calDebtMoney";
            this.calDebtMoney.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.calDebtMoney.Properties.Appearance.ForeColor = Color.Red;
            this.calDebtMoney.Properties.Appearance.Options.UseFont = true;
            this.calDebtMoney.Properties.Appearance.Options.UseForeColor = true;
            this.calDebtMoney.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calDebtMoney.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.calDebtMoney.Properties.ReadOnly = true;
            this.calDebtMoney.Size = new Size(0x7d, 20);
            this.calDebtMoney.StyleController = this.layoutControl1;
            this.calDebtMoney.TabIndex = 20;
            bits = new int[4];
            this.calPayMoney.EditValue = new decimal(bits);
            this.calPayMoney.Location = new Point(300, 0x76);
            this.calPayMoney.Name = "calPayMoney";
            this.calPayMoney.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.calPayMoney.Properties.Appearance.ForeColor = Color.Blue;
            this.calPayMoney.Properties.Appearance.Options.UseFont = true;
            this.calPayMoney.Properties.Appearance.Options.UseForeColor = true;
            this.calPayMoney.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calPayMoney.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.calPayMoney.Size = new Size(0x7e, 20);
            this.calPayMoney.StyleController = this.layoutControl1;
            this.calPayMoney.TabIndex = 0x13;
            this.calPayMoney.EditValueChanged += new EventHandler(this.calMoney_EditValueChanged);
            this.txtAssignmentName.Location = new Point(0x58, 6);
            this.txtAssignmentName.Name = "txtAssignmentName";
            this.txtAssignmentName.Size = new Size(0x152, 20);
            this.txtAssignmentName.StyleController = this.layoutControl1;
            this.txtAssignmentName.TabIndex = 0;
            this.dtFromDate.EditValue = null;
            this.dtFromDate.Location = new Point(0x58, 90);
            this.dtFromDate.Name = "dtFromDate";
            this.dtFromDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtFromDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtFromDate.Size = new Size(0x7c, 20);
            this.dtFromDate.StyleController = this.layoutControl1;
            this.dtFromDate.TabIndex = 3;
            this.dtDate.EditValue = null;
            this.dtDate.Location = new Point(300, 0xae);
            this.dtDate.Name = "dtDate";
            this.dtDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDate.Size = new Size(0x7e, 20);
            this.dtDate.StyleController = this.layoutControl1;
            this.dtDate.TabIndex = 8;
            this.txtReason.Location = new Point(0x58, 0x22);
            this.txtReason.Name = "txtReason";
            this.txtReason.Size = new Size(0x152, 20);
            this.txtReason.StyleController = this.layoutControl1;
            this.txtReason.TabIndex = 1;
            this.cboWhere.Location = new Point(0x58, 0x3e);
            this.cboWhere.Name = "cboWhere";
            this.cboWhere.Size = new Size(0x152, 20);
            this.cboWhere.StyleController = this.layoutControl1;
            this.cboWhere.TabIndex = 2;
            this.dtToDate.EditValue = null;
            this.dtToDate.Location = new Point(300, 90);
            this.dtToDate.Name = "dtToDate";
            this.dtToDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtToDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtToDate.Size = new Size(0x7e, 20);
            this.dtToDate.StyleController = this.layoutControl1;
            this.dtToDate.TabIndex = 4;
            bits = new int[4];
            this.calMoney.EditValue = new decimal(bits);
            this.calMoney.Location = new Point(0x58, 0x76);
            this.calMoney.Name = "calMoney";
            this.calMoney.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.calMoney.Properties.Appearance.ForeColor = Color.Green;
            this.calMoney.Properties.Appearance.Options.UseFont = true;
            this.calMoney.Properties.Appearance.Options.UseForeColor = true;
            this.calMoney.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calMoney.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.calMoney.Size = new Size(0x7c, 20);
            this.calMoney.StyleController = this.layoutControl1;
            this.calMoney.TabIndex = 5;
            this.calMoney.EditValueChanged += new EventHandler(this.calMoney_EditValueChanged);
            this.cboPerson.Location = new Point(0x58, 0xae);
            this.cboPerson.Name = "cboPerson";
            this.cboPerson.Size = new Size(0x7c, 20);
            this.cboPerson.StyleController = this.layoutControl1;
            this.cboPerson.TabIndex = 7;
            this.cboDecideNumber.Location = new Point(0x12d, 0x92);
            this.cboDecideNumber.Name = "cboDecideNumber";
            this.cboDecideNumber.Size = new Size(0x7d, 20);
            this.cboDecideNumber.StyleController = this.layoutControl1;
            this.cboDecideNumber.TabIndex = 6;
            this.layoutControlGroup1.CustomizationFormText = "layoutControlGroup1";
            this.layoutControlGroup1.EnableIndentsWithoutBorders = DefaultBoolean.True;
            this.layoutControlGroup1.GroupBordersVisible = false;
            this.layoutControlGroup1.Items.AddRange(new BaseLayoutItem[] { this.lcAssignmentName, this.lcReason, this.lcWhere, this.lcFromDate, this.lcToDate, this.lcDecidePerson, this.lcDate, this.lcDecideNumber, this.lcMoney, this.layoutControlItem1, this.layoutControlItem2 });
            this.layoutControlGroup1.Location = new Point(0, 0);
            this.layoutControlGroup1.Name = "layoutControlGroup1";
            this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(2, 2, 2, 2);
            this.layoutControlGroup1.Size = new Size(430, 0xc9);
            this.layoutControlGroup1.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0);
            this.layoutControlGroup1.Text = "layoutControlGroup1";
            this.layoutControlGroup1.TextVisible = false;
            this.lcAssignmentName.Control = this.txtAssignmentName;
            this.lcAssignmentName.CustomizationFormText = "layoutControlItem1";
            this.lcAssignmentName.Location = new Point(0, 0);
            this.lcAssignmentName.Name = "lcAssignmentName";
            this.lcAssignmentName.Size = new Size(0x1aa, 0x1c);
            this.lcAssignmentName.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcAssignmentName.Text = "Đi về việc:";
            this.lcAssignmentName.TextSize = new Size(80, 13);
            this.lcReason.Control = this.txtReason;
            this.lcReason.CustomizationFormText = "L\x00fd do đi:";
            this.lcReason.Location = new Point(0, 0x1c);
            this.lcReason.Name = "lcReason";
            this.lcReason.Size = new Size(0x1aa, 0x1c);
            this.lcReason.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcReason.Text = "L\x00fd do đi:";
            this.lcReason.TextSize = new Size(80, 13);
            this.lcWhere.Control = this.cboWhere;
            this.lcWhere.CustomizationFormText = "Đi đ\x00e2u:";
            this.lcWhere.Location = new Point(0, 0x38);
            this.lcWhere.Name = "lcWhere";
            this.lcWhere.Size = new Size(0x1aa, 0x1c);
            this.lcWhere.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcWhere.Text = "Đi đ\x00e2u:";
            this.lcWhere.TextSize = new Size(80, 13);
            this.lcFromDate.Control = this.dtFromDate;
            this.lcFromDate.CustomizationFormText = "Đi từ ng\x00e0y:";
            this.lcFromDate.Location = new Point(0, 0x54);
            this.lcFromDate.Name = "lcFromDate";
            this.lcFromDate.Size = new Size(0xd4, 0x1c);
            this.lcFromDate.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcFromDate.Text = "Đi từ ng\x00e0y:";
            this.lcFromDate.TextSize = new Size(80, 13);
            this.lcToDate.Control = this.dtToDate;
            this.lcToDate.CustomizationFormText = "Đến ng\x00e0y:";
            this.lcToDate.Location = new Point(0xd4, 0x54);
            this.lcToDate.Name = "lcToDate";
            this.lcToDate.Size = new Size(0xd6, 0x1c);
            this.lcToDate.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcToDate.Text = "Đến ng\x00e0y:";
            this.lcToDate.TextSize = new Size(80, 13);
            this.lcDecidePerson.Control = this.cboPerson;
            this.lcDecidePerson.CustomizationFormText = "Người ban h\x00e0nh:";
            this.lcDecidePerson.Location = new Point(0, 0xa8);
            this.lcDecidePerson.Name = "lcDecidePerson";
            this.lcDecidePerson.Size = new Size(0xd4, 0x1d);
            this.lcDecidePerson.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcDecidePerson.Text = "Người ban h\x00e0nh:";
            this.lcDecidePerson.TextSize = new Size(80, 13);
            this.lcDate.Control = this.dtDate;
            this.lcDate.CustomizationFormText = "Ng\x00e0y ban h\x00e0nh:";
            this.lcDate.Location = new Point(0xd4, 0xa8);
            this.lcDate.Name = "lcDate";
            this.lcDate.Size = new Size(0xd6, 0x1d);
            this.lcDate.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcDate.Text = "Ng\x00e0y ban h\x00e0nh:";
            this.lcDate.TextSize = new Size(80, 13);
            this.lcDecideNumber.Control = this.cboDecideNumber;
            this.lcDecideNumber.CustomizationFormText = "Số quyết định:";
            this.lcDecideNumber.Location = new Point(0xd5, 140);
            this.lcDecideNumber.Name = "lcDecideNumber";
            this.lcDecideNumber.Size = new Size(0xd5, 0x1c);
            this.lcDecideNumber.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcDecideNumber.Text = "Số quyết định:";
            this.lcDecideNumber.TextSize = new Size(80, 13);
            this.lcMoney.Control = this.calMoney;
            this.lcMoney.CustomizationFormText = "C\x00f4ng t\x00e1c ph\x00ed:";
            this.lcMoney.Location = new Point(0, 0x70);
            this.lcMoney.Name = "lcMoney";
            this.lcMoney.Size = new Size(0xd4, 0x1c);
            this.lcMoney.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.lcMoney.Text = "C\x00f4ng t\x00e1c ph\x00ed:";
            this.lcMoney.TextSize = new Size(80, 13);
            this.layoutControlItem1.Control = this.calPayMoney;
            this.layoutControlItem1.CustomizationFormText = "Thanh to\x00e1n:";
            this.layoutControlItem1.Location = new Point(0xd4, 0x70);
            this.layoutControlItem1.Name = "layoutControlItem1";
            this.layoutControlItem1.Size = new Size(0xd6, 0x1c);
            this.layoutControlItem1.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.layoutControlItem1.Text = "Thanh to\x00e1n:";
            this.layoutControlItem1.TextSize = new Size(80, 13);
            this.layoutControlItem2.Control = this.calDebtMoney;
            this.layoutControlItem2.CustomizationFormText = "C\x00f2n lại:";
            this.layoutControlItem2.Location = new Point(0, 140);
            this.layoutControlItem2.Name = "layoutControlItem2";
            this.layoutControlItem2.Size = new Size(0xd5, 0x1c);
            this.layoutControlItem2.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 2, 2);
            this.layoutControlItem2.Text = "Ghi v\x00e0o lương:";
            this.layoutControlItem2.TextSize = new Size(80, 13);
            this.labelControl7.Location = new Point(6, 0x117);
            this.labelControl7.Name = "labelControl7";
            this.labelControl7.Size = new Size(0x25, 13);
            this.labelControl7.TabIndex = 0x12;
            this.labelControl7.Text = "Tập tin:";
            this.labelControl7.Visible = false;
            this.txtFilePath.Location = new Point(0x30, 0x113);
            this.txtFilePath.Name = "txtFilePath";
            this.txtFilePath.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Glyph, "", -1, true, true, false, ImageLocation.MiddleCenter, (Image) manager.GetObject("txtFilePath.Properties.Buttons"), new KeyShortcut(Keys.None), appearance, "", "Browse", null, true) });
            this.txtFilePath.Properties.ButtonClick += new ButtonPressedEventHandler(this.txtFilePath_Properties_ButtonClick);
            this.txtFilePath.Size = new Size(0x55, 0x16);
            this.txtFilePath.TabIndex = 1;
            this.txtFilePath.TabStop = false;
            this.txtFilePath.Visible = false;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.grInformation);
            base.Controls.Add(this.labelControl7);
            base.Controls.Add(this.txtFilePath);
            base.Name = "xucAssignmentAdd";
            base.Size = new Size(0x1bb, 0x137);
            base.Controls.SetChildIndex(base.btnSaveNew, 0);
            base.Controls.SetChildIndex(base.btnSave, 0);
            base.Controls.SetChildIndex(base.btnCancel, 0);
            base.Controls.SetChildIndex(this.txtFilePath, 0);
            base.Controls.SetChildIndex(this.labelControl7, 0);
            base.Controls.SetChildIndex(this.grInformation, 0);
            ((ISupportInitialize) base.Err).EndInit();
            base.imageCollection2.EndInit();
            this.grInformation.EndInit();
            this.grInformation.ResumeLayout(false);
            this.grInformation.PerformLayout();
            this.txtEmployeeName.Properties.EndInit();
            this.glkEmployeeCode.Properties.EndInit();
            this.gridLookUpEdit1View.EndInit();
            this.layoutControl1.EndInit();
            this.layoutControl1.ResumeLayout(false);
            this.calDebtMoney.Properties.EndInit();
            this.calPayMoney.Properties.EndInit();
            this.txtAssignmentName.Properties.EndInit();
            this.dtFromDate.Properties.VistaTimeProperties.EndInit();
            this.dtFromDate.Properties.EndInit();
            this.dtDate.Properties.VistaTimeProperties.EndInit();
            this.dtDate.Properties.EndInit();
            this.txtReason.Properties.EndInit();
            this.cboWhere.Properties.EndInit();
            this.dtToDate.Properties.VistaTimeProperties.EndInit();
            this.dtToDate.Properties.EndInit();
            this.calMoney.Properties.EndInit();
            this.cboPerson.Properties.EndInit();
            this.cboDecideNumber.Properties.EndInit();
            this.layoutControlGroup1.EndInit();
            this.lcAssignmentName.EndInit();
            this.lcReason.EndInit();
            this.lcWhere.EndInit();
            this.lcFromDate.EndInit();
            this.lcToDate.EndInit();
            this.lcDecidePerson.EndInit();
            this.lcDate.EndInit();
            this.lcDecideNumber.EndInit();
            this.lcMoney.EndInit();
            this.layoutControlItem1.EndInit();
            this.layoutControlItem2.EndInit();
            this.txtFilePath.Properties.EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void InitMultiLanguages()
        {
            this.grInformation.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "grInformation", this.grInformation.Text);
            this.lcAssignmentName.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "AssignmentName", this.lcAssignmentName.Text);
            this.lcReason.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "Reason", this.lcReason.Text);
            this.lcWhere.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "Where", this.lcWhere.Text);
            this.lcFromDate.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "FromDate", this.lcFromDate.Text);
            this.lcToDate.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "ToDate", this.lcToDate.Text);
            this.lcDate.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "Date", this.lcDate.Text);
            this.lcMoney.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "Money", this.lcMoney.Text);
            this.lcDecidePerson.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "DecidePerson", this.lcDecidePerson.Text);
            this.lcDecideNumber.Text = MultiLanguages.GetString("tbl_ProcessAssignmentAdd", "DecideNumber", this.lcDecideNumber.Text);
        }

        private void LoadEmployeeInformation()
        {
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            this.grInformation.Text = "Th\x00f4ng Tin C\x00f4ng T\x00e1c - " + hrm_employee.EmployeeCode + " (" + hrm_employee.FirstName + " " + hrm_employee.LastName + ")";
            this.txtEmployeeName.Text = hrm_employee.FirstName + " " + hrm_employee.LastName;
        }

        private void RaiseSuccessEventHander(HRM_PROCESS_ASSIGNMENT item)
        {
            if (this.Success != null)
            {
                this.Success(this, item);
            }
        }

        public void SetCode(string EmployeeCode)
        {
            this.m_EmployeeCode = EmployeeCode;
            if (this.m_EmployeeCode != "")
            {
                this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
                this.LoadEmployeeInformation();
            }
        }

        public void SetCode(string EmployeeCode, DateTime FromDate, DateTime ToDate)
        {
            this.m_EmployeeCode = EmployeeCode;
            if (this.m_EmployeeCode != "")
            {
                this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
                this.LoadEmployeeInformation();
            }
            this.dtFromDate.DateTime = FromDate;
            this.dtToDate.DateTime = ToDate;
        }

        public void SetData(HRM_PROCESS_ASSIGNMENT item)
        {
            this.m_AssignmentID = item.AssignmentID;
            SYS_LOG.Insert("Qu\x00e1 Tr\x00ecnh Đi C\x00f4ng T\x00e1c", "Xem", this.m_AssignmentID.ToString());
            this.m_EmployeeCode = item.EmployeeCode;
            this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
            this.glkEmployeeCode.Enabled = false;
            this.txtAssignmentName.Text = item.AssignmentName;
            this.txtReason.Text = item.Reason;
            this.cboWhere.Text = item.Where;
            this.dtFromDate.DateTime = item.FromDate;
            this.dtToDate.DateTime = item.ToDate;
            this.calMoney.EditValue = item.Money;
            this.calPayMoney.EditValue = item.PayMoney;
            this.calDebtMoney.EditValue = item.DebtMoney;
            this.cboDecideNumber.Text = item.DecideNumber;
            this.dtDate.DateTime = item.Date;
            this.cboPerson.Text = item.Person;
            this.txtFilePath.Text = item.FilePath;
            this.LoadEmployeeInformation();
        }

        private void txtFilePath_Properties_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter = "All File(*.*)|*.*",
                FilterIndex = 0
            };
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.txtFilePath.Text = dialog.FileName;
            }
        }

        protected override string uc_Change()
        {
            return string.Empty;
        }

        protected override string uc_Delete()
        {
            HRM_PROCESS_ASSIGNMENT item = new HRM_PROCESS_ASSIGNMENT {
                AssignmentID = this.m_AssignmentID
            };
            string str = item.Delete();
            if (str == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            return str;
        }

        protected override string uc_Save()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessAssignment") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowAdd)
            {
                MyRule.Notify();
                return "";
            }
            if (this.m_EmployeeCode == "")
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn nh\x00e2n vi\x00ean để lưu dữ liệu!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK);
                return "";
            }
            SYS_LOG.Insert("Qu\x00e1 Tr\x00ecnh Đi C\x00f4ng T\x00e1c", "Th\x00eam", this.m_AssignmentID.ToString());
            base.SetWaitDialogCaption("Đang lưu dữ liệu...");
            Cursor.Current = Cursors.WaitCursor;
            HRM_PROCESS_ASSIGNMENT item = new HRM_PROCESS_ASSIGNMENT();
            item = this.InitClass();
            string text = item.Insert();
            if (text == "OK")
            {
                this.UpdateTimeKeeper();
                this.RaiseSuccessEventHander(item);
            }
            Cursor.Current = Cursors.Default;
            this.DoHide();
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return text;
        }

        protected override string uc_Update()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessAssignment") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowEdit)
            {
                MyRule.Notify();
                return "";
            }
            SYS_LOG.Insert("Qu\x00e1 Tr\x00ecnh Đi C\x00f4ng T\x00e1c", "Cập Nhật", this.m_AssignmentID.ToString());
            base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
            HRM_PROCESS_ASSIGNMENT item = new HRM_PROCESS_ASSIGNMENT();
            item = this.InitClass();
            item.AssignmentID = this.m_AssignmentID;
            string text = item.Update();
            if (text == "OK")
            {
                this.UpdateTimeKeeper();
                this.RaiseSuccessEventHander(item);
            }
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.DoHide();
            return text;
        }

        private void UpdateTimeKeeper()
        {
            clsTimeKeeperOption option = new clsTimeKeeperOption();
            if (option.AutoAssignment)
            {
                HRM_TIMEKEEPER hrm_timekeeper = new HRM_TIMEKEEPER();
                for (DateTime time = this.dtFromDate.DateTime.Date; time <= this.dtToDate.DateTime.Date; time = DateAndTime.DateAdd(DateInterval.Day, 1.0, time))
                {
                    foreach (DataRow row in hrm_timekeeper.GetListByDate(this.m_EmployeeCode, time).Rows)
                    {
                        if (row["ShiftCode"].ToString() != "")
                        {
                            hrm_timekeeper.UpdateSymbol(new Guid(row["TimeKeeperTableListID"].ToString()), row["EmployeeCode"].ToString(), row["ShiftCode"].ToString(), time.Date, "CT", time.Date, time.Date, 0.0, 0.0, 0.0, 0.0, 0, 0, false, true, 0, "");
                        }
                    }
                }
            }
        }

        public delegate void SuccessEventHander(object sender, HRM_PROCESS_ASSIGNMENT item);
    }
}

